package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IHomeService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.HomePageResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 主页显示
 * @author wxy
 * @date 2022-01-19 21:56
 * @version 1.0
 */
@RestController
@RequestMapping("/shopping")
public class HomepageController {


    @Reference(timeout = 3000,check = false)
    IHomeService iHomeService;
    @RequestMapping("/homepage")
    @Anoymous
    public ResponseData homepage(){
        HomePageResponse homepage = iHomeService.homepage();

        if (ShoppingRetCode.SUCCESS.getCode().equals(homepage.getCode())){
            //返回一个包含数据的ResponseData对象
            return  new ResponseUtil().setData(homepage.getPanelContentItemDtos());
        }
        //返回包含错误信息的ResponseData对象
        return new ResponseUtil().setErrorMsg(homepage.getMsg());
    }


}
